#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2018/4/2 15:43
# @Author  : LiMC
# @File    : lianxi.py
# @Software: PyCharm
#
# string = input("请输入字符串：")
# num = len([i for i in string.split()])
# print(num)
# 第一题
# L = [1,2,3,4,5,6,2,3]
# l = set(L)
# print(list(l))
# 第二题
# s = [9,7,8,3,2,1,55,6]
# num = len(s)
# s_min = min(s)
# s_max = max(s)
# s_sum = sum(s)
# s_ave = s_sum / num
# print("元素个数：{},最大值：{}, 最小值：{}, 元素和：{}, 平均值：{}.".format(num, s_max, s_min, s_sum, s_ave))
# 第三题
# s = [9,7,8,3,2,1,5,6]
# def pf(x):
#     if x % 2 == 0:
#         return x**2
#     else:
#         return x
#
# l = map(pf, s)
# print(list(l))
# 第五题
# s = input("请输入一个字符串：")
# AS = []
# for i in s:
#     AS.append(ord(i))
# print(AS)

#
# t = input("请输入字符串：")
# count = 1
# for i in t:
#     if i == " ":
#         count += 1
# print(str.format("其中的单词总数有：{0}", count))

import subprocess

# order1 = ['cd', 'E:\毕业设计\meituan\meituan\spiders']
# order2 = ['cd', '/home/leon/bysj']
# data = subprocess.Popen(order2, shell=True, stdout=subprocess.PIPE)
# print(data.stdout)
# for i in iter(data.stdout.readline, 'b'):
#     print(i)

def subprocess_cmd(command):
    process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
    proc_stdout = process.communicate()[0].strip()
    # proc_stdout = process.communicate()
    print(str(proc_stdout, encoding='utf-8'))

subprocess_cmd("cd /home/leon/bysj;ls")

# subprocess_cmd(r'E:\bysj\meituan\meituan\spiders; ping qq.com')
# subprocess_cmd(r'E:; cd bysj; ls')

# subprocess.Popen(r"ping qq.com",shell=True，stdout=subprocess.PIPE)




# import math
# x = int(input("请输入整数n（n>=o）"))
# # 递归
# def fact(n):
#     if n == 1: return 1
#     return n * fact(n-1)

# # 非递归
# jc = math.factorial(x)

# print('递归：{} != {}'.format(x, fact(x)))
# print('非递归: {} != {}'.format(x, jc))





# def fib(n):
#     i, a, b = 0, 0, 1
#     while i < n:
#         print("{:>5}  ".format(b), end="")
#         if i == 9: print()
#         a, b = b, a+b
#         i += 1


# fib(20)
# def fib(n):
#     a, b = 0, 1
#     while n:
#         print("{:>5}  ".format(b), end="")
#         if n == 11:  print()
#         a, b = b, a+b
#         n -= 1
#     return b


# fib(20)

# def minn(*args):
#     print(min(*args))

# minn([9,6,8,3,8,3,64,78])


# def cansu(*args):
#     l = {
#         'max': max(*args),
#         'min': min(*args),
#         'num': len(*args)
#     }
#     return l
# print(cansu([2,7,3,56,23,57,234,57,456,34,23]))







# import turtle


# turtle.screensize(800, 600, "green")
# turtle.penup()
# turtle.goto(-50, 100)
# turtle.pensize(20)
# turtle.pendown()
# # turtle.goto(-50, 100)
# turtle.pencolor("red")
# turtle.write("20160925", font=('SimHei',50,"SimHei"), align="center")
# turtle.end_fill()

# turtle.hideturtle()


# turtle.penup()
# t= turtle.Turtle()
# t.write("20160915", font=("微软雅黑", 54, "normal"))
# turtle.done()
# print('a')





